import request from '@/utils/request'

export function startProcess(data) {
  return request({
    url: '/instances/start',
    method: 'post',
    data
  })
}

export function completeTask(data) {
  return request({
    url: '/instances/complete',
    method: 'post',
    data
  })
}

export function getMyApplications() {
  return request({
    url: '/instances/my-applications',
    method: 'get'
  })
}

export function getMyTasks() {
  return request({
    url: '/instances/my-tasks',
    method: 'get'
  })
}

export function getMyCompletedTasks() {
  return request({
    url: '/instances/my-completed-tasks',
    method: 'get'
  })
}

export function getInstanceDetail(id) {
  return request({
    url: `/instances/${id}`,
    method: 'get'
  })
}

export function cancelInstance(id) {
  return request({
    url: `/instances/${id}/cancel`,
    method: 'post'
  })
}

// 转签任务
export function transferTask(taskId, targetUserId, reason) {
  return request({
    url: `/instances/task/${taskId}/transfer`,
    method: 'post',
    params: {
      targetUserId,
      reason
    }
  })
}

// 批量完成任务
export function batchCompleteTask(taskIds, action, comment) {
  return request({
    url: '/instances/batch-complete',
    method: 'post',
    data: {
      taskIds,
      action,
      comment
    }
  })
}

